package com.it.tydic.estate.module.controller.khgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.mapper.inner.TbFamilyMapper;
import com.it.tydic.estate.module.model.inner.TbFamily;
import com.it.tydic.estate.module.service.TbFamilyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.lang.annotation.AfterReturning;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @description:   家庭成员管理控制器
 * @author: liuhui
 * @createDate: 2020/3/5
 * @version: 1.0
 */
@RestController
@RequestMapping("family")
@Api(tags = "家庭成员管理")
public class FamilyController {
    @Autowired
    private TbFamilyService familyService; /*家庭成员*/
    /**
     * 家庭成员列表
     * @param map
     * @return
     */
    @PostMapping("/selectFamilyList")
    @ApiOperation(value = "家庭成员列表", notes = "家庭成员列表")
    public Result selectFamilyList(@RequestBody Map<String,Object> map){
        return familyService.selectFamilyList(map);
    }


    /**
     * 家庭成员列表
     * @param uid
     * @return
     */
    @GetMapping("/getById/{uid}")
    @ApiOperation(value = "家庭成员详情", notes = "家庭成员详情")
    public Result selectFamilyById(@RequestParam String uid){
        return familyService.selectFamilyById(uid);
    }


    /**
     * 家庭成员添加修改
     * @param tbFamily
     * @return
     */
    @PostMapping("/addFamily")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    @ApiOperation(value = "庭成员添加修改", notes = "庭成员添加修改")
    public Result addFamily(@RequestBody TbFamily tbFamily){
        return familyService.addFamily(tbFamily);
    }
    /**
     * 家庭成员删除（批量）
     * @param list
     * @return
     */
    @PostMapping("/delFamily")
    @ControllerDesc(description = LogConstants.delete_data)
    @ApiOperation(value = "家庭成员删除", notes = "家庭成员删除")
    public Result delFamily(@RequestBody List<String> list){
        return familyService.delFamily(list);
    }

}
